package com.hskn.hss.module.carPlanCar.controller;


import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hskn.hss.core.annotation.SysLog;
import com.hskn.hss.core.domain.BaseEntity;
import com.hskn.hss.core.enums.BusinessType;
import com.hskn.hss.core.utils.file.FileTypeUtils;
import com.hskn.hss.core.utils.poi.ExcelUtil;
import com.hskn.hss.entity.AjaxResult;
import com.hskn.hss.exception.ExcelReaderDataException;
import com.hskn.hss.module.carPlan.entity.CarPlan;
import com.hskn.hss.module.carPlan.mapper.CarPlanMapper;
import com.hskn.hss.module.carPlan.service.CarPlanService;
import com.hskn.hss.module.carPlan.to.CarPlanExcelReaderTO;
import com.hskn.hss.module.carPlan.to.CarPlanTo;
import com.hskn.hss.module.carPlan.to.CarWorkPlanCountTo;
import com.hskn.hss.module.carPlan.vo.JxqsPlanExportVo;
import com.hskn.hss.module.carPlan.vo.LjqyPlanExportVo;
import com.hskn.hss.module.carPlan.vo.LjzyPlanExportVo;
import com.hskn.hss.module.carPlanCar.service.CarPlanCarService;
import com.hskn.hss.module.carPlanCar.to.CarPlanCarTo;
import com.hskn.hss.module.common.ienum.ExcelTypeEnum;
import com.hskn.hss.module.workgroup.entity.WorkGroup;
import com.hskn.hss.module.workgroup.mapper.WorkGroupMapper;
import com.hskn.hss.module.workrule.entity.WorkRule;
import com.hskn.hss.module.workrule.mapper.WorkRuleMapper;
import com.hskn.hss.utils.Tools;
import com.hskn.hss.utils.page.PageVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author hskn
 * @since 2021-05-17
 */
@Slf4j
@RestController
@RequestMapping("/hss/carPlanCar")
public class CarPlanCarController {

    @Autowired
    private CarPlanCarService carPlanCarService;

    @RequestMapping(value = "carPlanWorkCount", method = RequestMethod.POST)
    public AjaxResult<Object> carPlanWorkCount(@RequestBody @Validated CarPlanCarTo carPlanCarTo) {
        try {
            return AjaxResult.success(carPlanCarService.carPlanWorkCount(carPlanCarTo));
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    @RequestMapping(value = "carPlanWorkDetail", method = RequestMethod.POST)
    public AjaxResult<Object> carPlanWorkDetail(@RequestBody @Validated CarPlanCarTo carPlanCarTo) {
        try {
            return AjaxResult.success(carPlanCarService.carPlanWorkDetail(carPlanCarTo));
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    @RequestMapping(value = "carPlanWorkDetailByCar", method = RequestMethod.POST)
    public AjaxResult<Object> carPlanWorkDetailByCar(@RequestBody @Validated CarPlanCarTo carPlanCarTo) {
        try {
            return AjaxResult.success(carPlanCarService.carPlanWorkDetailByCar(carPlanCarTo));
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    @RequestMapping(value = "trashPickupWorkPlanCount", method = RequestMethod.POST)
    public AjaxResult<Object> trashPickupWorkPlanCount() {
        try {
            return AjaxResult.success(carPlanCarService.trashPickupWorkPlanCount());
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    @RequestMapping(value = "trashPickupWorkPlanList", method = RequestMethod.POST)
    public AjaxResult<Object> trashPickupWorkPlanList() {
        try {
            return AjaxResult.success(carPlanCarService.trashPickupWorkPlanList());
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }


}

